import { createStore } from 'vuex';

export default createStore({
  state: {
    user: {
      id: 0,
      name: "",
      address: "",
      phone: "",
    }
  },
  mutations: {
    setUser(state, data){
      state.user.id = data.id;
      state.user.name = data.name;
      state.user.address = data.address;
      state.user.phone = data.phone;
    },
  },
  actions: {
    setUser(context, user_data){
      const data = {
        id: user_data.iduser,
        name: user_data.user_name,
        address: user_data.address,
        phone: user_data.phone,
      };
      context.commit("setUser", data);
    },
  },
  modules: {
  },
});
